package com.wuwei.controller;

import com.wuwei.service.ContentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * @description: ContentController <br>
 * @date: 2021/2/28 12:05 <br>
 * @author: wuwei666 <br>
 * @version: 1.0 <br>
 */
@RestController
public class ContentController {
    @Autowired
    private ContentService contentService;

    @GetMapping("/")
    public String gotoIndex(){
        return "index";
    }

    /*@GetMapping("/search/{keyword}/{pageNo}/{pageSize}/{index}")
    public List<Map<String,Object>> search(@PathVariable("keyword") String keyword,
                                           @PathVariable(value = "pageNo") int pageNo,
                                           @PathVariable(value = "pageSize") int pageSize,
                                           @PathVariable(value = "index") String index) throws IOException {
        List<Map<String, Object>> list = contentService.selectDocumentPage(keyword, pageNo, pageSize, index);
        return list;
    }*/

    @GetMapping("/search/{keyword}/{pageNo}/{pageSize}/{index}")
    public List<Map<String,Object>> search(@PathVariable("keyword") String keyword,
                                           @PathVariable(value = "pageNo") int pageNo,
                                           @PathVariable(value = "pageSize") int pageSize,
                                           @PathVariable(value = "index") String index) throws IOException {
        List<Map<String, Object>> list = contentService.selectDocumentHighLight(keyword, pageNo, pageSize, index);
        return list;
    }
}
